//
//  CLDataStructureTest.m
//  Charles
//
//  Created by Leo on 2019/6/27.
//  Copyright © 2019 charles. All rights reserved.
//

#import "CLDataStructureTest.h"
#import "CLBinaryTree.h"
#import "CLStack.h"
#import "CLQueue.h"

@implementation CLDataStructureTest

+ (void)testBinaryTree {
    CLBinaryTree *binaryTree = [[CLBinaryTree alloc]init];
    
    TreeNode *tree = [binaryTree makeBinaryTree];
    // 先序遍历
    [binaryTree preorderTraversal:tree];
    NSLog(@"**********************************");
    // 中序遍历
    [binaryTree inorderTraversal:tree];
    NSLog(@"**********************************");
    // 后序遍历
    [binaryTree postorderTraversal:tree];
    NSLog(@"**********************************");
    // 层次遍历
    [binaryTree levelTraversal:tree];
    
    NSInteger treeDepth = [binaryTree depthTree:tree];
    NSLog(@"二叉树深度为%d",(int)treeDepth);
}

+ (void)testInvertBinaryTree {
    CLBinaryTree *binaryTree = [[CLBinaryTree alloc]init];
    TreeNode *tree = [binaryTree makeBinaryTree];
    [binaryTree preorderTraversal:tree];
    
    TreeNode *invertedTree = [binaryTree invertBinaryTree:tree];
    // 先序遍历
     [binaryTree preorderTraversal:invertedTree];
    
}

+ (void)testArrayStack {
    CLArrayStack *arrayStack = [[CLArrayStack alloc]initWithCapacity:5];
    for (NSInteger i = 1; i < 8; i++) {
        [arrayStack push:i];
    }
}

+ (void)testArrayQueue {
    CLArrayQueue *arrayQueue = [[CLArrayQueue alloc]initWithCapacity:5];
    for (NSInteger i = 1; i < 8; i++) {
        [arrayQueue enqueue:i];
    }
}

@end
